{extend name="public/base"/}
{block name="body"}
<title>列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 数据管理 <span class="c-gray en">&gt;</span> 数据列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
            <a href="javascript:;" id="backup" class="btn btn-primary radius">备份</a>
            <a href="javascript:;" id="optimize" class="btn btn-success radius">优化</a>
            <a href="javascript:;" id="repair" class="btn btn-warning radius">修复</a>
        </span>
    </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
            <tr>
                <th scope="col" colspan="9">数据列表<span class="r">共有数据：<strong>{$result.tableNum}</strong> 条，共计：<strong>{$result.total}</strong></span></th>
            </tr>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="allselect"></th>
                <th width="100">数据库表</th>
                <th width="50">记录条数</th>
                <th width="60">占用空间</th>
                <th width="60">类型</th>
                <th width="100">编码</th>
                <th width="130">创建时间</th>
                <th width="100">说明</th>
            </tr>
        </thead>
        <tbody>
            {volist name='result.data' id='list' empty="$empty"}
            <tr class="text-c" id="val_{$list.name}">
                <td>
                    <input type="checkbox" value="{$list.name}" name="allcheck">
                </td>
                <td>{$list.name}</td>
                <td>{$list.rows}</td>
                <td>{$list.size}</td>
                <td>{$list.engine}</td>
                <td>{$list.collation}</td>
                <td>{$list.create_time}</td>
                <td>{$list.comment}</td>
            </tr>
            {/volist}
        </tbody>
    </table>
</div>

<script>
$("#backup").on('click',function(){
    var ids = new Array();
    var check = $("input[type=checkbox][name=allcheck]:checked");
    check.each(function(i){
        ids[i] = $(this).val();
    });
    layer.confirm('确认要备份吗？',function(index){
        $.ajax({
            type: 'POST',
            url: 'backup',
            data:{id:ids},
            success: function(data){
                layer.msg('已备份!',{icon:1,time:2000});
                setTimeout("location.reload()",2000);
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
});
$("#optimize").on('click',function(){
    var ids = new Array();
    var check = $("input[type=checkbox][name=allcheck]:checked");
    check.each(function(i){
        ids[i] = $(this).val();
    });
    layer.confirm('确认要优化吗？',function(index){
        $.ajax({
            type: 'POST',
            url: 'optimize',
            data:{id:ids},
            success: function(data){
                layer.msg('已优化!',{icon:1,time:2000});
                setTimeout("location.reload()",2000);
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
});
$("#repair").on('click',function(){
    var ids = new Array();
    var check = $("input[type=checkbox][name=allcheck]:checked");
    check.each(function(i){
        ids[i] = $(this).val();
    });
    layer.confirm('确认要修复吗？',function(index){
        $.ajax({
            type: 'POST',
            url: 'repair',
            data:{id:ids},
            success: function(data){
                layer.msg('已修复!',{icon:1,time:2000});
                setTimeout("location.reload()",2000);
            },
            error:function(data) {
                console.log(data.msg);
            },
        });     
    });
});
</script>
{/block}
